﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

/*
    2012-2-17 David检查正常
 */
namespace Benefit.Models.Sys
{
    /// <summary>
    /// 操作员每日的账户对应关系
    /// </summary>
    public class DayOperatorAccount
    {
        /// <summary>
        /// 编号
        /// </summary>
        public int Id { get; set; }
        /// <summary>
        /// 操作员编号
        /// </summary>
        public int OperatorId { get; set; }
        /// <summary>
        /// 操作员
        /// </summary>
        public virtual Operator Operator { get; set; }
        /// <summary>
        /// 账号编号
        /// </summary>
        public int AccountId { get; set; }
        /// <summary>
        /// 账号
        /// </summary>
        public virtual Account Account { get; set; }
        /// <summary>
        /// 时间
        /// </summary>
        public DateTime Pdate { get; set; }
        ///// <summary>
        ///// 初始化交易员账号关系
        ///// </summary>
        ///// <param name="_pdate"></param>
        //public void InitDayOperatorAccount(DateTime _pdate, DB.DBManager db)
        //{
        //    OperatorAccount oa = new OperatorAccount();
        //    var query = from t in db.OperatorAccount.Include(a => a.Account).Include(a => a.Operator) select t;
        //    foreach (Sys.OperatorAccount o in query)
        //    {
        //        if (!o.Account.IsDeleted && !o.Operator.IsDeleted)
        //        {
        //            DayOperatorAccount dgop = new DayOperatorAccount();
        //            dgop.Pdate = _pdate;
        //            dgop.AccountId = o.AccountId;
        //            dgop.OperatorId = o.OperatorId;
        //            db.DayOperatorAccounts.Add(dgop);
        //        }
        //    }

        //    db.SaveChanges();
        //}
        ///// <summary>
        ///// 删除操作员账号关系
        ///// </summary>
        ///// <param name="_pdate"></param>
        //public void DeleteDayOperatorAccount(DateTime _pdate, DB.DBManager db)
        //{
        //    DayOperatorAccount dgop = new DayOperatorAccount();
        //    var query = from t in db.DayOperatorAccounts where t.Pdate.Year == _pdate.Year && t.Pdate.Month == _pdate.Month && t.Pdate.Day == _pdate.Day select t;
        //    foreach (Sys.DayOperatorAccount o in query)
        //    {
        //        db.DayOperatorAccounts.Remove(o);
        //    }
        //    db.SaveChanges();
        //}
        ///// <summary>
        ///// 找到某一操作员某天的所有账号
        ///// </summary>
        ///// <param name="_pdate"></param>
        ///// <param name="operatorid"></param>
        ///// <returns></returns>
        //public List<Account> GetDayOperatorAccounts(DateTime _pdate, int operatorid, DB.DBManager db)
        //{
        //    DayOperatorAccount dgop = new DayOperatorAccount();
        //    List<Account> accounts = new List<Sys.Account>();
        //    var query = (from t in db.DayOperatorAccounts where t.Pdate.Year == _pdate.Year && t.Pdate.Month == _pdate.Month && t.Pdate.Day == _pdate.Day && t.OperatorId == operatorid select t).ToList();
        //    foreach (Sys.DayOperatorAccount o in query)
        //    {
        //        Account id = o.Account;
        //        accounts.Add(id);
        //    }
        //    return accounts;
        //}
    }
}
